package rudiments;

public class ArrayDemo {
	// 2147483647
	int[] array = new int[9];
	int count = 0;
	
	public void insert(int val) {
		if (count == array.length) {
			int sum = 0;
			for(int i=0; i<array.length; ++i) {
				sum = sum + array[i];
				System.out.println("sum = " + sum);
			}
			array[0] = sum;
			count = 1;
		}
		array[count] = val;
		++count;
		
		for(int i : array) {
			System.out.print(array[i]);
		}
	}
	
	public static void main(String[] args) {
		ArrayDemo ad = new ArrayDemo();
		ad.insert(2);
	}
}
